package routers

import (
	"HuiYi-Mall/utils/web"
	"github.com/gin-gonic/gin"
	"net/http"
)

type RouterInfo struct {
	Method  string
	Path    string
	Handler func(c *gin.Context)
	ReqIn   any // 用于知道接口的入参是什么
	RespOut any // 接口的出参
}

// InitRouters 初始化项目路由
func InitRouters(e *gin.Engine) {

	// 心跳路由
	e.GET("/ping", func(c *gin.Context) {
		c.JSON(http.StatusOK, web.SuccessResp(nil))
	})

	allRouters := make([]RouterInfo, 0)
	allRouters = append(allRouters, UserRouters...)
	for _, router := range allRouters {
		e.RouterGroup.Handle(router.Method, router.Path, router.Handler)
	}
}
